<template>
  <div>
        <van-field v-model="fromdata.username" placeholder="请输入账号"></van-field>
        <van-field v-model="fromdata.password" placeholder="请输入密码"></van-field>
        <van-button @click="confirmlogin">确认登陆</van-button>



  </div>
</template>

<script>
import axios from 'axios'
export default {
    data(){
        return{
            fromdata:{
                password:'',
                username:''
            }
        }
    },
    methods:{
        confirmlogin(){
            axios({url:'mylogin',method:'post',data:this.fromdata}).then(res=>{
                console.log(res);
                if(res.data.code == 200){
                    localStorage.setItem('userid',res.data.userid)
                    localStorage.setItem('token',res.data.token)
                    localStorage.setItem('url1',JSON.stringify(res.data.url1))
                    localStorage.setItem('username',res.data.username)
                    alert('登陆成功')
                }
            })
        }
    }

}
</script>

<style>

</style>